/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Vista;

import Vista.Controladoras.ControladoraVista;
import Vista.Ventanas.Movimientos.ABMMovimientos;
import Vista.Ventanas.PersonaLegal.ABMClientes;
import javax.swing.JFrame;

/**
 *
 * @author Luciano
 */
public class VentanaPrincipal extends javax.swing.JFrame {

    /**
     * Creates new form VentanaPrincipal
     */
    protected ControladoraVista miControladora = new ControladoraVista();
    private int menuActivo = 0;
    private ABMClientes ABMCliente;
    private ABMMovimientos ABMMovimiento;

    public VentanaPrincipal() {
        initComponents();
        setearMenu();
        this.setExtendedState(JFrame.MAXIMIZED_BOTH);
    }

    public void setearMenu() {
        menuART.setVisible(false);
        menuVehiculos.setVisible(false);
        menuProveedores.setVisible(false);
        menuProductos.setVisible(false);
        menuPlantaciones.setVisible(false);
        menuPersonas.setVisible(false);
        menuPersonal.setVisible(false);
        menuMovimientos.setVisible(false);
        menuMatPrima.setVisible(false);
        menuMPPropias.setVisible(false);
        menuMPAjenas.setVisible(false);
        menuClientes.setVisible(false);
        menuCalculoDensidades.setVisible(false);
        menuMovimientosVER.setVisible(false);
        menuTrazabilidad.setVisible(false);

        switch (menuActivo) {
            case 0:
                menuART.setVisible(true);
                menuVehiculos.setVisible(true);
                menuProveedores.setVisible(true);
                menuProductos.setVisible(true);
                menuPlantaciones.setVisible(true);
                menuPersonas.setVisible(true);
                menuPersonal.setVisible(true);
                menuMovimientos.setVisible(true);
                menuMatPrima.setVisible(true);
                menuMPPropias.setVisible(true);
                menuMPAjenas.setVisible(true);
                menuClientes.setVisible(true);
                break;
            case 1:
                menuCalculoDensidades.setVisible(true);
                menuMovimientosVER.setVisible(true);
                menuTrazabilidad.setVisible(true);
                break;
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDesktopPane1 = new javax.swing.JDesktopPane();
        jPanel2 = new javax.swing.JPanel();
        jSlider1 = new javax.swing.JSlider();
        jMenuBar1 = new javax.swing.JMenuBar();
        menuPersonas = new javax.swing.JMenu();
        menuClientes = new javax.swing.JMenu();
        menuABMCliente = new javax.swing.JMenuItem();
        menuPersonal = new javax.swing.JMenu();
        menuABMPersonal = new javax.swing.JMenuItem();
        menuProveedores = new javax.swing.JMenu();
        menuABMProveedores = new javax.swing.JMenuItem();
        menuART = new javax.swing.JMenu();
        menuABMART = new javax.swing.JMenuItem();
        menuMovimientos = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        menuMatPrima = new javax.swing.JMenu();
        menuMPPropias = new javax.swing.JMenu();
        menuMPPYerbaVerde = new javax.swing.JMenuItem();
        menuMPAjenas = new javax.swing.JMenu();
        menuMPAYerbaVerde = new javax.swing.JMenuItem();
        menuMPALeña = new javax.swing.JMenuItem();
        menuProductos = new javax.swing.JMenu();
        menuPlantaciones = new javax.swing.JMenu();
        menuVehiculos = new javax.swing.JMenu();
        menuCalculoDensidades = new javax.swing.JMenu();
        menuItemDensidadPlantacion = new javax.swing.JMenuItem();
        menuItemDensidadSecadero = new javax.swing.JMenuItem();
        menuMovimientosVER = new javax.swing.JMenu();
        menuTrazabilidad = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jDesktopPane1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jDesktopPane1.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION);

        jSlider1.setMajorTickSpacing(1);
        jSlider1.setMaximum(3);
        jSlider1.setPaintTicks(true);
        jSlider1.setToolTipText("");
        jSlider1.setValue(0);
        jSlider1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSlider1StateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        menuPersonas.setText("Personas");

        menuClientes.setText("Clientes");

        menuABMCliente.setText("ABM Cliente");
        menuABMCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuABMClienteActionPerformed(evt);
            }
        });
        menuClientes.add(menuABMCliente);

        menuPersonas.add(menuClientes);

        menuPersonal.setText("Personal");

        menuABMPersonal.setText("ABM Personal");
        menuPersonal.add(menuABMPersonal);

        menuPersonas.add(menuPersonal);

        menuProveedores.setText("Proveedores");

        menuABMProveedores.setText("ABM Proveedores");
        menuProveedores.add(menuABMProveedores);

        menuPersonas.add(menuProveedores);

        menuART.setText("ART");

        menuABMART.setText("ABM ART");
        menuART.add(menuABMART);

        menuPersonas.add(menuART);

        jMenuBar1.add(menuPersonas);

        menuMovimientos.setText("Movimientos");
        menuMovimientos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuMovimientosActionPerformed(evt);
            }
        });

        jMenuItem1.setText("ABM Movimientos");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        menuMovimientos.add(jMenuItem1);

        jMenuBar1.add(menuMovimientos);

        menuMatPrima.setText("Materia Prima");

        menuMPPropias.setText("Propias");

        menuMPPYerbaVerde.setText("Yerba Verde");
        menuMPPropias.add(menuMPPYerbaVerde);

        menuMatPrima.add(menuMPPropias);

        menuMPAjenas.setText("Ajenas");

        menuMPAYerbaVerde.setText("Yerba Verde");
        menuMPAjenas.add(menuMPAYerbaVerde);

        menuMPALeña.setText("Leña");
        menuMPAjenas.add(menuMPALeña);

        menuMatPrima.add(menuMPAjenas);

        jMenuBar1.add(menuMatPrima);

        menuProductos.setText("Productos");
        jMenuBar1.add(menuProductos);

        menuPlantaciones.setText("Plantaciones");
        jMenuBar1.add(menuPlantaciones);

        menuVehiculos.setText("Vehiculos");
        jMenuBar1.add(menuVehiculos);

        menuCalculoDensidades.setText("Calculo de Densidades");

        menuItemDensidadPlantacion.setText("Densidad Plantacion");
        menuCalculoDensidades.add(menuItemDensidadPlantacion);

        menuItemDensidadSecadero.setText("Densidad Secadero");
        menuCalculoDensidades.add(menuItemDensidadSecadero);

        jMenuBar1.add(menuCalculoDensidades);

        menuMovimientosVER.setText("Movimientos");
        jMenuBar1.add(menuMovimientosVER);

        menuTrazabilidad.setText("Trazabilidad");
        jMenuBar1.add(menuTrazabilidad);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 951, Short.MAX_VALUE)
            .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void menuABMClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuABMClienteActionPerformed
        if (ABMCliente == null) {
            ABMCliente = new ABMClientes(miControladora);
            jDesktopPane1.add(ABMCliente);
            ABMCliente.show();
        }
    }//GEN-LAST:event_menuABMClienteActionPerformed

    private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSlider1StateChanged
        switch (jSlider1.getValue()) {
            case 0:
                menuActivo = 0;
                break;
            case 1:
                menuActivo = 1;
                break;

        }
        setearMenu();
    }//GEN-LAST:event_jSlider1StateChanged

    private void menuMovimientosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuMovimientosActionPerformed
    }//GEN-LAST:event_menuMovimientosActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        if (ABMMovimiento == null) {
            ABMMovimiento = new ABMMovimientos(miControladora);
            jDesktopPane1.add(ABMMovimiento);
            ABMMovimiento.show();
        }
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(VentanaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(VentanaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(VentanaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(VentanaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VentanaPrincipal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JSlider jSlider1;
    private javax.swing.JMenuItem menuABMART;
    private javax.swing.JMenuItem menuABMCliente;
    private javax.swing.JMenuItem menuABMPersonal;
    private javax.swing.JMenuItem menuABMProveedores;
    private javax.swing.JMenu menuART;
    private javax.swing.JMenu menuCalculoDensidades;
    private javax.swing.JMenu menuClientes;
    private javax.swing.JMenuItem menuItemDensidadPlantacion;
    private javax.swing.JMenuItem menuItemDensidadSecadero;
    private javax.swing.JMenuItem menuMPALeña;
    private javax.swing.JMenuItem menuMPAYerbaVerde;
    private javax.swing.JMenu menuMPAjenas;
    private javax.swing.JMenuItem menuMPPYerbaVerde;
    private javax.swing.JMenu menuMPPropias;
    private javax.swing.JMenu menuMatPrima;
    private javax.swing.JMenu menuMovimientos;
    private javax.swing.JMenu menuMovimientosVER;
    private javax.swing.JMenu menuPersonal;
    private javax.swing.JMenu menuPersonas;
    private javax.swing.JMenu menuPlantaciones;
    private javax.swing.JMenu menuProductos;
    private javax.swing.JMenu menuProveedores;
    private javax.swing.JMenu menuTrazabilidad;
    private javax.swing.JMenu menuVehiculos;
    // End of variables declaration//GEN-END:variables
}
